# Maintainer : Christian Rebischke <Chris.Rebischke@archlinux.org>
# Maintainer : Caleb Maclennan <caleb@alerque.com>
# Contributor: Eli Schwartz <eschwartz@archlinux.org>
# Contributor: Giovanni Scafora <giovanni@archlinux.org>
# Contributor: lucke <lucke at o2 dot pl>

pkgname=weechat
pkgver=4.1.1
pkgrel=1
pkgdesc="Fast, light and extensible IRC client (curses UI)"
arch=('loong64' 'x86_64')
url="https://www.weechat.org/"
license=('GPL')
depends=('gnutls' 'curl' 'libgcrypt')
makedepends=('asciidoctor' 'cmake' 'enchant' 'guile' 'lua' 'perl' 'python'
             'ruby' 'tcl')
optdepends=('enchant: spellchecker support'
            'guile: support for guile scripts'
            'lua: support for lua scripts'
            'perl: support for perl scripts'
            'python: support for python scripts'
            'ruby: support for ruby scripts'
            'tcl: support for tcl scripts')
source=("https://www.weechat.org/files/src/${pkgname}-${pkgver}.tar.xz"{,.asc})
sha512sums=('9d6bae5cc0c11cf3d06b0f9e457d01e76d240e8737e683a5c8a1bc89a1102b5ba75b2c59629df9433ba6a5ed42152d4390713618e646089acb7947000d9872d5'
            'SKIP')
b2sums=('5a2d5042de0871eabf65b71e1172f891044692cf468aab6fe99f6b6b188826f9a6c227fe7140948907d0b76a5001d644e8efc8a6ac8490b961af12d777f5a29a'
        'SKIP')
validpgpkeys=('A9AB5AB778FA5C3522FD0378F82F4B16DEC408F8') # WeeChat (signing key) <webmaster@weechat.org>

# cmake does not correctly handle CPPFLAGS, so kludge it in anyway:
# https://gitlab.kitware.com/cmake/cmake/-/issues/12928
CFLAGS+=" ${CPPFLAGS}"

build() {
  cmake -B build -S ${pkgname}-${pkgver} \
        -DCMAKE_BUILD_TYPE=None \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DENABLE_MAN=ON \
        -DENABLE_DOC=ON \
        -DENABLE_DOC_INCOMPLETE=ON \
        -DENABLE_ENCHANT=ON \
        -DENABLE_JAVASCRIPT=OFF \
        -DENABLE_PHP=OFF \
        -Wno-dev
  cmake --build build
}

package() {
  DESTDIR="${pkgdir}" cmake --install build
}
